import {buchheim, Tree} from './Tree';
import {MinHeap} from "./Heap";

export function getTree(n,algo=0,r=0, input=[], key = 0){
    if(algo === 1)
        return buchheim(fac() );
    else if( algo === 0 )
        return buchheim(ifElse([50, 100, 200]));
    else if( algo === 4 )
        return buchheim(ifElse2([1000, 500]));
}

function temp() {
    let leftTree = new Tree(1, undefined, new Tree(2));

    return new Tree(0, leftTree, undefined);
}


function fac() {
    return new Tree(0, new Tree(0, undefined, undefined, ""), new Tree(0, undefined, undefined, ""), ">1");
}


function ifElseItem(conditionList, index, symbol) {

    let tree = new Tree(index,undefined, undefined, symbol + conditionList[index]);
    console.log("tree.label", tree.label);
    let treeYes = new Tree("Yes", undefined, undefined, "");
    tree.left = treeYes;
    let treeNo;
    if (index !== conditionList.length - 1) {
        treeNo = ifElseItem(conditionList, index + 1, symbol);
    } else {
        treeNo = new Tree("No", undefined, undefined, "");
    }
    tree.right = treeNo;
    return tree;
}


function ifElse(input) {
    let conditionList = [...input];
    let tree = ifElseItem(conditionList, 0, "<");
    return tree;
}




function ifElse2(input) {
    let conditionList = [...input];
    let tree = ifElseItem(conditionList, 0, "≥");
    return tree;
}
